package org.zj.webview.type;

import lombok.Getter;
import org.zj.webview.WebViewApi;

/**
 * 指针引用
 *
 * @author zj
 * @since 2025/3/31
 */
@Getter
abstract class NativeRef {

    /**
     * 引用id，由JNI赋值
     */
    private final long id;

    NativeRef() {
        this.id = 0L;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        NativeRef nativeRef = (NativeRef) o;
        return id == nativeRef.id;
    }

    public abstract boolean isValid();


    @Override
    public int hashCode() {
        return Long.valueOf(id).hashCode();
    }


    @Override
    public String toString() {
        return "NativeRef{id=" + id + '}';
    }
}
